#include "tipwidget.h"

TipWidget::TipWidget(QString tip, QWidget *parent) : BaseWidget(parent)
{
    setStyleSheet(".QWidget{background: transparent;}");

    QWidget *w = new QWidget(this);
    w->move((1024-600)/2, (600-300)/2);
    w->setFixedSize(600, 300);
    w->setStyleSheet(".QWidget{background:white;border-radius:30px;}");

    QLabel *label = new QLabel(w);
    label->setStyleSheet("QLabel{color:#000;font-size: 30px;background:transparent}");
    label->setText(tip);
    label->setGeometry(0,0,w->width(), 200);
    label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

    QPushButton *btn = new QPushButton(w);
    btn->setStyleSheet("QPushButton{border: 1px solid #2094fa;border-radius:20px;font-size:30px;background-color:#2094fa}");
    btn->setGeometry((w->width()-120)/2, 210, 120, 60);
    btn->setText("确定");
    connect(btn, &QPushButton::clicked, this, [&]
    {
        close();
    });
}

void TipWidget::KeyEvent(Key_t type, int key)
{
    switch (key)
    {
        case 0:
        {
            if(type == KEY_PRESS || type==KEY_REPEAT)
            {

            }
        }
        case 1:
        {
            if(type == KEY_PRESS)
            {
                close();
            }
        }
        case 2:
        {
            if(type == KEY_PRESS)
            {
                close();
            }
        }
    }
}
